package com.betterjr.modules.application.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.modules.application.data.ApplicationCustRoleConstantCollections;

/**
 * 每个操作员应用表（包括操作员个性化设置）
 * @ClassName: ApplicationOperator 
 * @Description: 每个操作员应用表（包括操作员个性化设置） 
 * @author xuyp
 * @date 2017年11月17日 上午11:33:10 
 *
 */
@Access(AccessType.FIELD)
@Entity
@Table(name = "t_ams_application_operator")
public class ApplicationOperator implements BetterjrEntity {

    /** 
     * @Fields serialVersionUID :  
     */
    private static final long serialVersionUID = -3949719859333377425L;

    /**
     * 流水号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "流水号", comments = "流水号")
    private Long id;

    /**
     * 操作员id
     */
    @Column(name = "l_operator_id", columnDefinition = "INTEGER")
    @MetaData(value = "操作员id", comments = "操作员id")
    private Long operatorId;

    /**
     * 应用id
     */
    @Column(name = "l_applicaiton_id", columnDefinition = "INTEGER")
    @MetaData(value = "应用id", comments = "应用id")
    private Long applicationId;

    /**
     * 操作员名称
     */
    @Column(name = "c_operator_name", columnDefinition = "VARCHAR")
    @MetaData(value = "操作员名称", comments = "操作员名称")
    private String operatorName;

    /**
     * 是否是个性定制应用   1 是   2 不是
     */
    @Column(name = "c_proprity", columnDefinition = "VARCHAR")
    @MetaData(value = "是否是个性定制应用   1 是   2 不是", comments = "是否是个性定制应用   1 是   2 不是")
    private String proprity;

    /**
     * 个性定制显示的优先级 越小越优先
     */
    @Column(name = "n_proprity_level", columnDefinition = "INTEGER")
    @MetaData(value = "个性定制显示的优先级 越小越优先", comments = "个性定制显示的优先级 越小越优先")
    private int proprityLevel;

    /**
     * 是否拦截  1 默认不拦截   2 拦截
     */
    @Column(name = "c_filterflag", columnDefinition = "VARCHAR")
    @MetaData(value = "是否拦截  1 默认不拦截   2 拦截", comments = "是否拦截  1 默认不拦截   2 拦截")
    private String filterFalg;

    /**
     * 状态 1未生效 2已生效 9已失效
     */
    @Column(name = "c_businStatus", columnDefinition = "VARCHAR")
    @MetaData(value = "状态 1未生效 2已生效 9已失效", comments = "状态 1未生效 2已生效 9已失效")
    private String businStatus;

    public Long getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(Long operatorId) {
        this.operatorId = operatorId;
    }

    public String getOperatorName() {
        return operatorName;
    }

    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }

    public String getProprity() {
        return proprity;
    }

    public void setProprity(String proprity) {
        this.proprity = proprity;
    }

    public int getProprityLevel() {
        return proprityLevel;
    }

    public void setProprityLevel(int proprityLevel) {
        this.proprityLevel = proprityLevel;
    }

    public String getFilterFalg() {
        return filterFalg;
    }

    public void setFilterFalg(String filterFalg) {
        this.filterFalg = filterFalg;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getApplicationId() {
        return applicationId;
    }

    public void setApplicationId(Long applicationId) {
        this.applicationId = applicationId;
    }

    public String getBusinStatus() {
        return businStatus;
    }

    public void setBusinStatus(String businStatus) {
        this.businStatus = businStatus;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((applicationId == null) ? 0 : applicationId.hashCode());
        result = prime * result + ((businStatus == null) ? 0 : businStatus.hashCode());
        result = prime * result + ((filterFalg == null) ? 0 : filterFalg.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((operatorId == null) ? 0 : operatorId.hashCode());
        result = prime * result + ((operatorName == null) ? 0 : operatorName.hashCode());
        result = prime * result + ((proprity == null) ? 0 : proprity.hashCode());
        result = prime * result + proprityLevel;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof ApplicationOperator)) {
            return false;
        }
        ApplicationOperator other = (ApplicationOperator) obj;
        if (applicationId == null) {
            if (other.applicationId != null) {
                return false;
            }
        } else if (!applicationId.equals(other.applicationId)) {
            return false;
        }
        if (businStatus == null) {
            if (other.businStatus != null) {
                return false;
            }
        } else if (!businStatus.equals(other.businStatus)) {
            return false;
        }
        if (filterFalg == null) {
            if (other.filterFalg != null) {
                return false;
            }
        } else if (!filterFalg.equals(other.filterFalg)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (operatorId == null) {
            if (other.operatorId != null) {
                return false;
            }
        } else if (!operatorId.equals(other.operatorId)) {
            return false;
        }
        if (operatorName == null) {
            if (other.operatorName != null) {
                return false;
            }
        } else if (!operatorName.equals(other.operatorName)) {
            return false;
        }
        if (proprity == null) {
            if (other.proprity != null) {
                return false;
            }
        } else if (!proprity.equals(other.proprity)) {
            return false;
        }
        if (proprityLevel != other.proprityLevel) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ApplicationOperator [id=" + id + ", operatorId=" + operatorId + ", applicationId=" + applicationId
                + ", operatorName=" + operatorName + ", proprity=" + proprity + ", proprityLevel=" + proprityLevel
                + ", filterFalg=" + filterFalg + ", businStatus=" + businStatus + "]";
    }

    public ApplicationOperator saveAddValue(Long anApplicationId, Long anOperatorId) {
        this.setApplicationId(anApplicationId);
        this.setOperatorId(anOperatorId);
        this.setId(SerialGenerator.getLongValue("ApplicationOperator.id"));
        this.setBusinStatus(ApplicationCustRoleConstantCollections.APPLICATIONCUSTROLE_BUSINSTATUS_EFFECTIVE);
        return this;
    }

}
